//
//  NSString+YMJHA_1.m
//  MD5
//
//  Created by 殷殷明静 on 16/8/16.
//  Copyright © 2016年 殷明静. All rights reserved.
//

#import "NSString+YMJHA_1.h"
#import <CommonCrypto/CommonCrypto.h>
@implementation NSString (YMJHA_1)
- (NSString *)stringWithSHA_1 {
    const char *cString = [self UTF8String];
    CC_LONG len = (CC_LONG)strlen(cString);
    unsigned char bytes[CC_SHA1_DIGEST_LENGTH];
    CC_SHA1(cString, len, bytes);
    NSMutableString *string = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH];
    for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
        [string appendFormat:@"%02x",bytes[i]];
    }
    return string;
}
@end
